/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Lasse
 */
public class QuickArray<Item> {
    private int count = 0;
    private Item[] array = (Item[])new Object[2];
    
    public void add(Item item)
    {
        if(count == array.length)
            reBuild(count*2);
        array[count] = item;
        count++;
    }
    
    private void reBuild(int size)
    {
        Item[] tmparray = (Item[])new Object[size];
        for(int i = 0; i<count;i++)
        {
            tmparray[i] = array[i];
        }
        array = tmparray;
    }
    
    public Double[] getDoubleArray()
    {
        Double[] tmparray = new Double[count];
        for(int i = 0; i<count;i++)
        {
            tmparray[i] = (Double)array[i];
        }
        return tmparray;
    }
}
